package com.amap.map.network.handler;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.amap.map.util.Configuration;

import android.util.Log;

public class CustomExecutorService {

	private ExecutorService executorService; 		// 线程池
	private static final int POOL_MULTIPLE = 4 ; 	// 线程池中工作线程的数目
	private static CustomExecutorService instance;

	private CustomExecutorService() {
		// 创建一个线程池                            可用处理器数*线程池工作数
		executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * POOL_MULTIPLE);
		Log.i( Configuration.LOG_NAME," CustomExecutorService  数据分析线程池启动....");
	}

	public synchronized static CustomExecutorService getInstance() {
		if (instance == null) {
			instance = new CustomExecutorService();
		}
		return instance;
	}

	public void execute( Runnable thread ) {
		executorService.execute(thread);
	}

}
